package com.lingshu.customview.utils;

import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;

/**
 * bitmap工具类
 */
class BitmapUtils {

    /**
     * 获取图片的DPI
     *
     * @param bitmap
     * @return
     */
    public static int getDpi(Bitmap bitmap) {
        return bitmap.getDensity();
    }

    public Bitmap getBitmapFromPhotoView(Drawable drawable) {
        if (drawable instanceof BitmapDrawable) {
            return ((BitmapDrawable) drawable).getBitmap();
        }
        return null;
    }
}
